$(function(){
	/**
	 * 加载评论
	 */
	addEstimateBySong();
	
	$("#submit").click(function(){
		addEstimate();
	});
});

/**
 * 加载评论
 */
function addEstimateBySong(){
	var song_id=$("#song_song_id").val();
	$.post(path + "/song/addEstimateBySong.do", {"song_id":song_id}, function(result) {
		if (result.success) {
			$("#player_estimate").empty();
			var list = result.data;
			$(list).each(function() {
				var div='<div id="r_r1"><div class="master">评论歌曲：'+this.song_name+'</div><div id="r_r2"><div style="width: 50px; height: 50px;margin-top:20px;margin-left: 5px;"><img src="../image/user/'+this.head+'" border="0" width="50" height="50"/></div><div id="r_r3" >'+this.user_name+'</div></div><div id="r_r4">&nbsp;&nbsp; 评论内容：</div><div style="width: 91%;height:80px;;float: left;text-align: left;font-size: 13px">'+this.estimate_info+'</div></div>';
				$("#player_estimate").append(div);
			});
		} else {
			alert(result.message);
		}
	});
}


/**
 * 发表评论
 */
function addEstimate(){
	var song_id=$("#songid").val();
	var textarea=$("#textarea").val();
	$.post(path + "/song/addEstimate.do", {"song_id":song_id,"textarea":textarea}, function(result) {
		if (result.success) {
			var data = result.data;
			var song_name=$("#song_song_name").val();
			var user_head=$("#user_head").val();
			var user_name=$("#user_user_name").val();
			var div='<div id="r_r1"><div class="master">评论歌曲：'+song_name+'</div><div id="r_r2"><div style="width: 50px; height: 50px;margin-top:20px;margin-left: 5px;"><img src="../image/user/'+user_head+'" border="0" width="50" height="50"/></div><div id="r_r3" >'+user_name+'</div></div><div id="r_r4">&nbsp;&nbsp; 评论内容：</div><div style="width: 91%;height:80px;;float: left;text-align: left;font-size: 13px">'+data.estimate_info+'</div></div>';
			$("#player_estimate").prepend(div);
			$("#textarea").html("");
		} else {
			alert(result.message);
		}
	});
}

//var flashvars = {
//	f : 'mv/<%=request.getAttribute("headAddress")%>',
//	c : 0,
//	b : 1
//};
//var params = {
//	bgcolor : '#FFF',
//	allowFullScreen : true,
//	allowScriptAccess : 'always'
//};
//CKobject.embedSWF('../ckplayer/ckplayer.swf', 'a1', 'ckplayer_a1', '600', '400',
//		flashvars, params);
///*
// * CKobject.embedSWF(播放器路径,容器id,播放器id/name,播放器宽,播放器高,flashvars的值,其它定义也可省略);
// * 下面三行是调用html5播放器用到的
// */
//var video = ['http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4',
//		'http://www.ckplayer.com/webm/0.webm->video/webm',
//		'http://www.ckplayer.com/webm/0.ogv->video/ogg'];
//var support = ['iPad', 'iPhone', 'ios', 'android+false', 'msie10+false'];
//CKobject.embedHTML5('video', 'ckplayer_a1', 600, 400, video, flashvars, support);

